const CURRENT_GOODS = 'current_goods'

const state = {
  currentGoods: JSON.parse(window.localStorage.getItem(CURRENT_GOODS)) || null
}

const mutations = {
  CHANGE_CURRENT_GOODS(state, data) {
    window.localStorage.setItem(CURRENT_GOODS, JSON.stringify(data))
    state.currentGoods = data
  }
}

const actions = {
  changeCurrentGoods({ commit }, data) {
    commit('CHANGE_CURRENT_GOODS', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
